clc;clear;clearvars;
load('iris_X.mat', 'iris');
x = iris;
load('iris_Y.mat', 'iris');
y = iris;
% num表示有多少个类标签
num = 3;
n = size(x, 1);
m = size(x, 2);
z = zeros(num, m);
z_lable = [1; 2; 3];
for i = 1 : num
    z(i, :) = sum(x(y == i, :), 1) ./ sum(y == i);
end
% cnp
test_y = zeros(n, 1);
for i = 1 : n
    Dist = sum((x(i, :) - z).^2,2);
    [~,I] = min(Dist);
    test_y(i, :) = I;
end
err_num = sum(test_y ~= y);
fprintf("cnp: iris total: %d err_num: %d\n",n,err_num);
